package com.example.mybank.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.mybank.entity.engine;
import com.example.mybank.mapper.EngineMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/engine")
public class EngineController {

    @Autowired
    engine engineDefault;

    @Autowired
    EngineMapper engineMapper;


    @GetMapping("/all")
    public List<engine> getAll(){
        return engineMapper.selectList(null);
    }

    @GetMapping("/get/{engineID}")
    public List<engine> get(@PathVariable("engineID")Long engineID){
        QueryWrapper<engine> queryWrapper = new QueryWrapper();
        queryWrapper.eq("id",engineID);
        return engineMapper.selectList(queryWrapper);
    }

    @PostMapping("/set")
    public Boolean set(@RequestBody engine engine){
//        BeanUtils.copyProperties(riskEngineConfiguration, this.riskEngineConfiguration);
        return 1== engineMapper.updateById(engine);
    }

    @PostMapping("/add")
    public Boolean add(@RequestBody engine engine){
//        BeanUtils.copyProperties(riskEngineConfiguration, this.riskEngineConfiguration);
        engineMapper.insert(engine);
        return true;
    }


}
